﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CARMSBusiness
{
    public static class ListExtender
    {

        public static string SeperateToString(this IEnumerable<object> objInput, string strSeperateChar)
        {
            var strReturn = string.Empty;

            int intIndex = 0;
            foreach (var obj in objInput)
            {
                if (obj.ToString().Trim().Length > 0)
                {
                    if (intIndex > 0)
                    {
                        strReturn += strSeperateChar + obj;
                    }
                    else
                    {
                        strReturn += obj;
                    }
                    intIndex++;
                }

            }
            return strReturn;
        }

        public static string SeperateToString(this IEnumerable<object> objInput, char strSeperateChar)
        {
            var strReturn = string.Empty;

            int intIndex = 0;
            foreach (var obj in objInput)
            {
                if (obj.ToString().Trim().Length > 0)
                {
                    if (intIndex > 0)
                    {
                        strReturn += strSeperateChar + obj.ToString();
                    }
                    else
                    {
                        strReturn += obj;
                    }
                    intIndex++;
                }

            }
            return strReturn;
        }
        public static string SeperateToString(this IEnumerable<string> objInput, string strSeperateChar)
        {
            var strReturn = string.Empty;
            int intIndex = 0;
            foreach (var obj in objInput)
            {
                if (obj.Trim().Length > 0)
                {
                    if (intIndex > 0)
                    {
                        strReturn += strSeperateChar + obj;
                    }
                    else
                    {
                        strReturn += obj;
                    }
                    intIndex++;
                } 

            }
            return strReturn;
        }



        public static string SeperateToString(this IEnumerable<string> objInput, char strSeperateChar)
        {
            var strReturn = string.Empty;
            int intIndex = 0;
            foreach (var obj in objInput)
            {
                if (obj.Trim().Length > 0)
                {
                    if (intIndex > 0)
                    {
                        strReturn += strSeperateChar + obj;
                    }
                    else
                    {
                        strReturn += obj;
                    }
                    intIndex++;
                }

            }
            return strReturn;
        }

        public static string SeperateListToString(this List<Guid> objInput, string strSeperateChar)
        {
            var strReturn = string.Empty;
            int intIndex = 0;
            foreach (var obj in objInput)
            {
                if (obj.ToString().Trim().Length > 0)
                {
                    if (intIndex > 0)
                    {
                        strReturn += strSeperateChar + obj;
                    }
                    else
                    {
                        strReturn += obj;
                    }
                    intIndex++;
                }

            }
            return strReturn;
        }

        public static string SeperateListToString(this List<string> objInput, string strSeperateChar)
        {
            var strReturn = string.Empty;
            int intIndex = 0;
            foreach (var obj in objInput)
            {
                if (obj.Trim().Length > 0)
                {
                    if (intIndex > 0)
                    {
                        strReturn += strSeperateChar + obj;
                    }
                    else
                    {
                        strReturn += obj;
                    }
                    intIndex++;
                }

            }
            return strReturn;
        }

    }
}
